#ifndef _PDU_MAKE_HEADER_H
#define _PDU_MAKE_HEADER_H

#define  ARR_SIZE( a )  ( sizeof( (a) ) / sizeof( (a[0]) ) )
#define  MASK_B(offset, len) ((0xff >> offset) & (0xff << (8 - (offset + len))))
#define  MAX_TRANSFOR_LENTH 1024
#define  MAX_MESSAGE_LENGTH 281
typedef enum{false=0,true=1}bool;
typedef enum
{
ENCODING_NONE    = 0,
ENCODING_ASCII   = 2,
ENCODING_UNICODE = 4,
ENCODING_MAX     = 5,
}message_encoding_format;

typedef enum
{
DO_MAKE_NONE               = -1,
PDU_MAKE_HEAD              =  0,
PDU_MAKE_ADDR              =  1,
PDU_MAKE_BEAR              =  2,
PDU_MAKE_DATA_CONTROL      =  3,
PDU_MAKE_DATA_RESPCODE     =  4,
PDU_MAKE_DATA_SMSPACK      =  5,
PDU_MAKE_DATA_TIMEPACK     =  6,
DO_MAKE_MAX                =  7,
}work_index_enum_type;

typedef bool (*pdu_made_handle_type)( unsigned char *,unsigned char *);

typedef struct
{
  const work_index_enum_type event;
  const pdu_made_handle_type event_handler;
} do_pdu_made_entry_type;
typedef struct
{
unsigned char            input_buf[MAX_TRANSFOR_LENTH];      //输入的短信内容，需要放入内容
unsigned char            output_buf[MAX_MESSAGE_LENGTH];     //输出的短信内容，需要提前清空
unsigned char            dst_addr[33];                       //目标电话号码，需要存放数据
int                      output_length;                      //输出短信的长度，需要清空
message_encoding_format  encoding;                           //短信编码方式
unsigned char            control_data_length;                //raw_ts子段长度
}do_pdu_made_data_type;


/************************************
function
************************************/
bool do_bit_set(unsigned char *dst,unsigned char src,int offset,int len);
bool message_asciitohex(unsigned char *dsc,unsigned char *src,int len);
bool do_build(work_index_enum_type index,unsigned char *dst,unsigned char *src);

bool do_head_build_handle(unsigned char *dst, unsigned char *src);
bool do_addr_build_handle(unsigned char *dst, unsigned char *src);
bool do_bear_build_handle(unsigned char *dst, unsigned char *src);

bool do_data_control_respcode_handle(unsigned char *dst, unsigned char *src);
bool do_data_control_build_handle(unsigned char *dst, unsigned char *src);
bool do_data_control_smspack_handle(unsigned char *dst, unsigned char *src);
bool do_data_control_timepack_handle(unsigned char *dst, unsigned char *src);
#endif
